#include <iostream>
using namespace std;

#define BOARD_X 1025
#define BOARD_Y 1025

int board[BOARD_X][BOARD_Y];


void reset ()
{
	for (int i = 0; i < BOARD_X; ++i)
	{
		for (int j = 0; j < BOARD_Y; ++j)
		{
			board[i][j] = 0;
		}
	}
}


void add_population (int x, int y, int p, int d)
{
	int xmin, ymin, xmax, ymax;
	xmin = max (x - d, 0);
	ymin = max (y - d, 0);
	xmax = min (x + d, BOARD_X - 1);
	ymax = min (y + d, BOARD_Y - 1);

	for (int i = xmin; i <= xmax; ++i)
	{
		for (int j = ymin; j <= ymax; ++j)
		{
			board[i][j] += p;
		}
	}
}


void best_bomb (int &x, int &y, int &p)
{
	p = 0;
	for (int i = 0; i < BOARD_X; ++i)
	{
		for (int j = 0; j < BOARD_Y; ++j)
		{
			if (board[i][j] > p)
			{
				x = i;
				y = j;
				p = board[i][j];
			}
		}
	}
}


int main ()
{
	int t, d, n, x, y, p;

	cin >> t;
	while (t--)
	{
		reset();
		cin >> d >> n;
		while (n--)
		{
			cin >> x >> y >> p;
			add_population (x, y, p, d);
		}
		best_bomb (x, y, p);
		cout << x << ' ' << y << ' ' << p << '\n';
	}
}